#include "pch.hpp"

#include <WinUi/Application.hpp>
#include <engine.core/info.hpp>
#include <engine/Engine.hpp>

#include "Application.hpp"
#include "MainWindow.hpp"




int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
	try
	{
		Application theApp(lpCmdLine);
		MainWindow window(theApp.provider());

		return theApp.exec();
	}
	catch(const boostext::exception& except)
	{
		std::string what     = except.what();
		std::string file     = except.file();
		std::string function = except.function();
		std::size_t line     = except.line();

		std::string text = boostext::format("An exception has been caught!\nWhat: %1%\nFunction: %2%\nWhere: %3%:%4%") % what % function % file % line;

		WinUi::Application::messageBox("An error ocurred", text);
	}
	catch(const std::exception& except)
	{
		std::string text = boostext::format("An exception has been caught!\nWhat: %1%") % except.what();
		WinUi::Application::messageBox("An error occured", text);
	}
	catch(...)
	{
		WinUi::Application::messageBox("An error occured", "An unknown exception has been caught!");
	}

	return -1;
}
///////////////////////////////////////////////////////////////////////////////////////////////////
